VERSION 5.00
Object = "{C4847593-972C-11D0-9567-00A0C9273C2A}#8.0#0"; "crviewer.dll"
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "msdatgrd.ocx"
Object = "{B3FB64BF-91F9-11D7-A482-0008A14158BC}#2.22#0"; "ITGControls.ocx"
Begin VB.Form frmMaintPriceMatrix 
   BackColor       =   &H00F7D9C2&
   BorderStyle     =   0  'None
   Caption         =   "Form1"
   ClientHeight    =   7050
   ClientLeft      =   945
   ClientTop       =   1140
   ClientWidth     =   11175
   BeginProperty Font 
      Name            =   "Tahoma"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MDIChild        =   -1  'True
   ScaleHeight     =   7050
   ScaleWidth      =   11175
   ShowInTaskbar   =   0   'False
   Begin MSComctlLib.StatusBar sbRS 
      Align           =   2  'Align Bottom
      Height          =   285
      Left            =   0
      TabIndex        =   15
      Top             =   6765
      Width           =   11175
      _ExtentX        =   19711
      _ExtentY        =   503
      _Version        =   393216
      BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628} 
         NumPanels       =   5
         BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Object.Width           =   3528
            MinWidth        =   3528
         EndProperty
         BeginProperty Panel2 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
         EndProperty
         BeginProperty Panel3 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Alignment       =   1
            AutoSize        =   1
            Bevel           =   0
            Object.Width           =   6484
            MinWidth        =   2
         EndProperty
         BeginProperty Panel4 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Object.Width           =   3528
            MinWidth        =   3528
         EndProperty
         BeginProperty Panel5 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Object.Width           =   3528
            MinWidth        =   3528
         EndProperty
      EndProperty
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
   End
   Begin ITGControls.ComunionFrames ComunionFrames2 
      Height          =   3735
      Left            =   0
      Top             =   2895
      Width           =   11040
      _ExtentX        =   19473
      _ExtentY        =   6588
      FrameColor      =   4210752
      BackColor       =   16243138
      FillColor       =   16243138
      RoundedCorner   =   0   'False
      Caption         =   "Details"
      Alignment       =   0
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ThemeColor      =   5
      ColorFrom       =   16243138
      ColorTo         =   16250865
      Begin VB.ComboBox cboUnit 
         Appearance      =   0  'Flat
         BackColor       =   &H00FFFFFF&
         Height          =   315
         ItemData        =   "frmMaintPriceMatrix.frx":0000
         Left            =   360
         List            =   "frmMaintPriceMatrix.frx":0002
         Style           =   2  'Dropdown List
         TabIndex        =   25
         Top             =   2760
         Width           =   1470
      End
      Begin MSDataGridLib.DataGrid dtgDetail 
         Height          =   3315
         Left            =   0
         TabIndex        =   9
         Top             =   420
         Width           =   11040
         _ExtentX        =   19473
         _ExtentY        =   5847
         _Version        =   393216
         AllowUpdate     =   -1  'True
         AllowArrows     =   -1  'True
         Enabled         =   -1  'True
         HeadLines       =   1
         RowHeight       =   15
         TabAcrossSplits =   -1  'True
         TabAction       =   2
         FormatLocked    =   -1  'True
         AllowDelete     =   -1  'True
         BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ColumnCount     =   7
         BeginProperty Column00 
            DataField       =   "cItemNo"
            Caption         =   "Product ID"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column01 
            DataField       =   "cDesc"
            Caption         =   "Description"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column02 
            DataField       =   "cUnit"
            Caption         =   "Unit"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   1
               Format          =   "#,##0.00"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   1
            EndProperty
         EndProperty
         BeginProperty Column03 
            DataField       =   "nPrice"
            Caption         =   "Price"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   1
               Format          =   "#,##0.00"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   1
            EndProperty
         EndProperty
         BeginProperty Column04 
            DataField       =   "cDiscount"
            Caption         =   "Discount"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column05 
            DataField       =   "cPartNo"
            Caption         =   "Internal Barcode"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column06 
            DataField       =   "cBarcodeID"
            Caption         =   "Barcode ID"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   "#,##0.00"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         SplitCount      =   1
         BeginProperty Split0 
            BeginProperty Column00 
               ColumnAllowSizing=   0   'False
               Button          =   -1  'True
               ColumnWidth     =   1574.929
            EndProperty
            BeginProperty Column01 
               Locked          =   -1  'True
               ColumnWidth     =   3569.953
            EndProperty
            BeginProperty Column02 
               ColumnAllowSizing=   0   'False
               Button          =   -1  'True
               Locked          =   -1  'True
               ColumnWidth     =   689.953
            EndProperty
            BeginProperty Column03 
               Alignment       =   1
               ColumnAllowSizing=   0   'False
               ColumnWidth     =   1154.835
            EndProperty
            BeginProperty Column04 
               ColumnAllowSizing=   0   'False
            EndProperty
            BeginProperty Column05 
               ColumnAllowSizing=   0   'False
               Locked          =   -1  'True
               ColumnWidth     =   1305.071
            EndProperty
            BeginProperty Column06 
               ColumnAllowSizing=   -1  'True
               ColumnWidth     =   1635.024
            EndProperty
         EndProperty
      End
   End
   Begin ITGControls.ITGTab SSTab1 
      Height          =   6630
      Left            =   0
      TabIndex        =   0
      Top             =   15
      Width           =   11040
      _ExtentX        =   19473
      _ExtentY        =   11695
      TabCount        =   2
      TabCaption(0)   =   "               Main               "
      TabContCtrlCnt(0)=   1
      Tab(0)ContCtrlCap(1)=   "ComunionFrames1"
      TabCaption(1)   =   "               List               "
      TabContCtrlCnt(1)=   1
      Tab(1)ContCtrlCap(1)=   "dtgList"
      TabTheme        =   2
      ActiveTabBackStartColor=   16250865
      ActiveTabBackEndColor=   16243138
      InActiveTabBackStartColor=   16243138
      InActiveTabBackEndColor=   16243138
      InActiveTabForeColor=   0
      BeginProperty ActiveTabFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty InActiveTabFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      OuterBorderColor=   4210752
      TopLeftInnerBorderColor=   4210752
      BottomRightInnerBorderColor=   4210752
      DisabledTabBackColor=   16243138
      DisabledTabForeColor=   -2147483630
      Begin MSDataGridLib.DataGrid dtgList 
         Height          =   2580
         Left            =   -75000
         TabIndex        =   10
         Top             =   315
         Width           =   11040
         _ExtentX        =   19473
         _ExtentY        =   4551
         _Version        =   393216
         HeadLines       =   1
         RowHeight       =   15
         FormatLocked    =   -1  'True
         BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ColumnCount     =   6
         BeginProperty Column00 
            DataField       =   "cPMID"
            Caption         =   "Price Matrix ID"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column01 
            DataField       =   "cDesc"
            Caption         =   "Decription"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column02 
            DataField       =   "dDate"
            Caption         =   "Date"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column03 
            DataField       =   "cCategory"
            Caption         =   "Category"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column04 
            DataField       =   "dEffectDate"
            Caption         =   "Effectivity Date"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column05 
            DataField       =   "cType"
            Caption         =   "Type"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         SplitCount      =   1
         BeginProperty Split0 
            BeginProperty Column00 
               Locked          =   -1  'True
            EndProperty
            BeginProperty Column01 
               ColumnWidth     =   2459.906
            EndProperty
            BeginProperty Column02 
               Locked          =   -1  'True
            EndProperty
            BeginProperty Column03 
               Locked          =   -1  'True
            EndProperty
            BeginProperty Column04 
               Locked          =   -1  'True
            EndProperty
            BeginProperty Column05 
            EndProperty
         EndProperty
      End
      Begin ITGControls.ComunionFrames ComunionFrames1 
         Height          =   2580
         Left            =   0
         Top             =   315
         Width           =   11040
         _ExtentX        =   19473
         _ExtentY        =   4551
         FrameColor      =   4210752
         BackColor       =   16243138
         FillColor       =   16243138
         RoundedCorner   =   0   'False
         Caption         =   "Header Information"
         Alignment       =   0
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ThemeColor      =   5
         ColorFrom       =   16243138
         ColorTo         =   16250865
         Begin VB.Timer Timer1 
            Interval        =   300
            Left            =   3135
            Top             =   420
         End
         Begin VB.OptionButton optCategory 
            BackColor       =   &H00F7D9C2&
            Caption         =   "Price"
            Height          =   330
            Index           =   0
            Left            =   750
            TabIndex        =   11
            Top             =   1560
            Value           =   -1  'True
            Width           =   1905
         End
         Begin VB.OptionButton optCategory 
            BackColor       =   &H00F7D9C2&
            Caption         =   "Discount"
            Height          =   330
            Index           =   1
            Left            =   750
            TabIndex        =   12
            Top             =   1875
            Width           =   1905
         End
         Begin VB.ComboBox cboType 
            Appearance      =   0  'Flat
            BackColor       =   &H00FFFFFF&
            Height          =   315
            ItemData        =   "frmMaintPriceMatrix.frx":0004
            Left            =   4395
            List            =   "frmMaintPriceMatrix.frx":0017
            Style           =   2  'Dropdown List
            TabIndex        =   5
            Top             =   1575
            Width           =   1470
         End
         Begin VB.CommandButton cmdPickCode 
            Enabled         =   0   'False
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   300
            Left            =   5910
            Picture         =   "frmMaintPriceMatrix.frx":0051
            Style           =   1  'Graphical
            TabIndex        =   7
            Top             =   1905
            Width           =   315
         End
         Begin ITGControls.ITGTextBox txtPMCode 
            Height          =   285
            Left            =   285
            TabIndex        =   1
            Top             =   540
            Width           =   2820
            _ExtentX        =   4763
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            BackColor       =   14745599
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Mandatory       =   -1  'True
            Label           =   "Price Matrix ID"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1300
            TextBoxWidth    =   1460
            TextTrim        =   -1  'True
            Required        =   -1  'True
         End
         Begin ITGControls.ITGDateBox dtbDate 
            Height          =   285
            Left            =   9330
            TabIndex        =   2
            Top             =   540
            Width           =   1365
            _ExtentX        =   2408
            _ExtentY        =   503
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Text            =   ""
            SendKeysTab     =   -1  'True
         End
         Begin ITGControls.ITGDateBox dtbEffecDate 
            Height          =   285
            Left            =   9330
            TabIndex        =   4
            Top             =   855
            Width           =   1365
            _ExtentX        =   2408
            _ExtentY        =   503
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Text            =   ""
            SendKeysTab     =   -1  'True
         End
         Begin ITGControls.ITGTextBox txtPMDesc 
            Height          =   285
            Left            =   285
            TabIndex        =   3
            Top             =   855
            Width           =   5595
            _ExtentX        =   9657
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Label           =   "Description"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1300
            TextBoxWidth    =   4235
            TextTrim        =   -1  'True
            Required        =   -1  'True
         End
         Begin ITGControls.ITGTextBox txtType 
            Height          =   285
            Left            =   4665
            TabIndex        =   16
            Tag             =   "cboIntTerms"
            Top             =   1605
            Visible         =   0   'False
            Width           =   1155
            _ExtentX        =   1931
            _ExtentY        =   503
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Mandatory       =   -1  'True
            Label           =   "Internal Terms"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   0
            TextBoxWidth    =   1095
         End
         Begin ITGControls.ITGTextBox txtCategory 
            Height          =   285
            Left            =   945
            TabIndex        =   18
            Tag             =   "cboIntTerms"
            Top             =   1605
            Visible         =   0   'False
            Width           =   1155
            _ExtentX        =   1931
            _ExtentY        =   503
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Mandatory       =   -1  'True
            Label           =   "Internal Terms"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   0
            TextBoxWidth    =   1095
         End
         Begin ITGControls.ITGTextBox txtName 
            Height          =   285
            Left            =   6240
            TabIndex        =   8
            TabStop         =   0   'False
            Top             =   1905
            Width           =   3570
            _ExtentX        =   6191
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            BackColor       =   14737632
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Label           =   "ITGtext"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   0
            TextBoxWidth    =   3510
            Enabled         =   0   'False
         End
         Begin VB.ComboBox cboCType 
            Appearance      =   0  'Flat
            BackColor       =   &H00FFFFFF&
            Height          =   315
            ItemData        =   "frmMaintPriceMatrix.frx":019B
            Left            =   4395
            List            =   "frmMaintPriceMatrix.frx":01AB
            Style           =   2  'Dropdown List
            TabIndex        =   6
            Top             =   1905
            Width           =   1470
         End
         Begin VB.ComboBox cboArea 
            Appearance      =   0  'Flat
            BackColor       =   &H00FFFFFF&
            Height          =   315
            ItemData        =   "frmMaintPriceMatrix.frx":01D7
            Left            =   4395
            List            =   "frmMaintPriceMatrix.frx":01E7
            Style           =   2  'Dropdown List
            TabIndex        =   13
            Top             =   3
            Width           =   1485
         End
         Begin VB.ComboBox cboTerms 
            Appearance      =   0  'Flat
            BackColor       =   &H00FFFFFF&
            Height          =   315
            ItemData        =   "frmMaintPriceMatrix.frx":0212
            Left            =   4395
            List            =   "frmMaintPriceMatrix.frx":0222
            Style           =   2  'Dropdown List
            TabIndex        =   19
            Top             =   1905
            Width           =   1470
         End
         Begin ITGControls.ITGTextBox txtCode 
            Height          =   285
            Left            =   4410
            TabIndex        =   17
            Top             =   1905
            Width           =   1425
            _ExtentX        =   2408
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Mandatory       =   -1  'True
            Label           =   "Reference"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   0
            TextBoxWidth    =   1365
            TextTrim        =   -1  'True
         End
         Begin VB.Label Label5 
            AutoSize        =   -1  'True
            BackStyle       =   0  'Transparent
            Caption         =   "Effectivity Date"
            Height          =   195
            Left            =   7980
            TabIndex        =   24
            Top             =   915
            Width           =   1125
         End
         Begin VB.Label Label3 
            AutoSize        =   -1  'True
            BackStyle       =   0  'Transparent
            Caption         =   "Date"
            Height          =   195
            Left            =   8760
            TabIndex        =   23
            Top             =   585
            Width           =   345
         End
         Begin VB.Label Label4 
            AutoSize        =   -1  'True
            BackStyle       =   0  'Transparent
            Caption         =   "Category"
            BeginProperty Font 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00000000&
            Height          =   195
            Index           =   0
            Left            =   120
            TabIndex        =   22
            Top             =   1275
            Width           =   780
         End
         Begin VB.Label Label1 
            AutoSize        =   -1  'True
            BackStyle       =   0  'Transparent
            Caption         =   "Type"
            Height          =   195
            Left            =   3330
            TabIndex        =   21
            Top             =   1650
            Width           =   360
         End
         Begin VB.Label Label2 
            AutoSize        =   -1  'True
            BackStyle       =   0  'Transparent
            Caption         =   "Reference"
            Height          =   195
            Left            =   3345
            TabIndex        =   20
            Top             =   1980
            Width           =   750
         End
      End
      Begin CRVIEWERLibCtl.CRViewer ITGReportViewer 
         Height          =   6200
         Left            =   -74940
         TabIndex        =   14
         Top             =   360
         Visible         =   0   'False
         Width           =   10500
         lastProp        =   500
         _cx             =   5080
         _cy             =   5080
         DisplayGroupTree=   0   'False
         DisplayToolbar  =   -1  'True
         EnableGroupTree =   0   'False
         EnableNavigationControls=   -1  'True
         EnableStopButton=   -1  'True
         EnablePrintButton=   -1  'True
         EnableZoomControl=   -1  'True
         EnableCloseButton=   -1  'True
         EnableProgressControl=   -1  'True
         EnableSearchControl=   -1  'True
         EnableRefreshButton=   0   'False
         EnableDrillDown =   -1  'True
         EnableAnimationControl=   -1  'True
         EnableSelectExpertButton=   0   'False
         EnableToolbar   =   -1  'True
         DisplayBorder   =   0   'False
         DisplayTabs     =   0   'False
         DisplayBackgroundEdge=   -1  'True
         SelectionFormula=   ""
         EnablePopupMenu =   -1  'True
         EnableExportButton=   -1  'True
         EnableSearchExpertButton=   0   'False
         EnableHelpButton=   0   'False
         LaunchHTTPHyperlinksInNewBrowser=   -1  'True
      End
   End
End
Attribute VB_Name = "frmMaintPriceMatrix"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'IT Group Inc. 2005.09.23

Option Explicit

'Object variables




Private oPrint As New clsPrinting

'Recordset variables
Private WithEvents rsHeader As ADODB.Recordset
Attribute rsHeader.VB_VarHelpID = -1
Private rsDetail As ADODB.Recordset

'Form mode enumeration
Enum ePMMode
    Normal
    AddNewEdit
    Find
End Enum
Public Mode As ePMMode

'Other declarations
Public dtgName As String
Public sBit As String
Private vBM As Variant 'Recordset bookmark variable

'ADO Connection variables

Private connHeader As ADODB.Connection
Private connDetail As ADODB.Connection

Private lLessPercent As Boolean
Private lLessAmount As Boolean
'Security Acess Level variables

Public lACNew As Boolean
Public lACEdit As Boolean
Public lACDelete As Boolean
Public lACPost As Boolean
Public lACCancel As Boolean
Public lACPrint As Boolean
    
Private Sub cboArea_Click()
    txtCode = Trim(cboArea)
End Sub

Private Sub cboArea_KeyPress(KeyAscii As Integer)
    SendKeysTab KeyAscii
End Sub

Private Sub cboCType_Click()
    txtCode = Trim(cboCType)
End Sub

Private Sub cboCType_KeyPress(KeyAscii As Integer)
    SendKeysTab KeyAscii
End Sub

Private Sub cboTerms_Click()
    txtCode = Trim(cboTerms)
End Sub

Private Sub cboTerms_KeyPress(KeyAscii As Integer)
    SendKeysTab KeyAscii
End Sub

Private Sub cboType_Click()
    txtType = Trim(cboType)
    If GetValueFrTable("lBit", "SYSTEM_OPTION", "cCode = 'ITM_MAN_BARCODE'") = True Then
        If Trim(cboType) = "Customer" Then
            dtgDetail.Columns(4).Visible = False
        Else
            dtgDetail.Columns(4).Visible = True
        End If
        dtgDetail.Columns(5).Visible = True
        dtgDetail.Columns(6).Visible = True
    Else
        dtgDetail.Columns(5).Visible = False
        dtgDetail.Columns(6).Visible = False
    End If
End Sub

Private Sub cboType_KeyPress(KeyAscii As Integer)
    SendKeysTab KeyAscii
    Select Case Trim(cboType)
        Case "Area"
            SendKeysTab KeyAscii
        Case "Terms"
            SendKeysTab KeyAscii
        Case "Customer Type"
            SendKeysTab KeyAscii
    End Select
End Sub

Private Sub cboUnit_Click()
    rsDetail!cUnit = cboUnit
End Sub

Private Sub cboUnit_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = 13 Then
        If dtgDetail.Col = 3 Then
            rsDetail!cUnit = cboUnit
            cboUnit.Visible = False
            dtgDetail.Col = 3
            dtgDetail.SetFocus
        End If
    ElseIf KeyCode = vbKeyEscape Then
        cboUnit.Visible = False
    End If
End Sub

Private Sub cboUnit_LostFocus()
    cboUnit.Visible = False
End Sub

Private Sub cmdPickCode_Click()
    If lPickListActive Then Exit Sub
    sFilterString = Trim(txtCode)
        Select Case Trim(cboType)
            Case "Customer"
                frmITGPicker.zType = QCustomer
            Case "Market Segment"
                frmITGPicker.zType = QMarketSegment
        End Select
    
    frmITGPicker.Show vbModal
    txtCode = frmITGPicker.zCode
    
    If rsDetail.RecordCount = 0 Then
        TBNewLine
        dtgDetail.LeftCol = 0
    End If
End Sub

Private Sub dtgDetail_ButtonClick(ByVal ColIndex As Integer)
    If Mode <> AddNewEdit Then Exit Sub
'        Select Case ColIndex
'        Case 0
'            sFilterString = Trim(dtgDetail.Columns(0).Text)
'            frmITGPicker.zType = QProduct
'            frmITGPicker.Show vbModal
'            rsDetail!cItemNo = Trim(frmITGPicker.zCode) & ""
'            If (Trim(frmITGPicker.zName) & "") <> "" Then
'                GetInitialItemValues
'            End If
'        Case 2
'            If dtgDetail.Columns(0).Text <> "" Then
'                Call LoadComboValues(cboUnit, "cUnit", "ITEM_UNIT", "WHERE cItemNo = '" & Trim(dtgDetail.Columns(0).Text) & "'", "cUnit")
'                Call MoveCombo(cboUnit, dtgDetail, dtgDetail.Columns(2))
'                ComboLoadValue cboUnit, Trim(dtgDetail.Columns(2).Text)
'            End If
'        End Select
End Sub

'Private Sub dtgList_HeadClick(ByVal ColIndex As Integer)
'    SortGrid dtgList, ColIndex, rsHeader
'End Sub

Private Sub dtgDetail_AfterColUpdate(ByVal ColIndex As Integer)
Dim i As Integer
    If Mode <> AddNewEdit Then Exit Sub
    If ColIndex = 4 Then
        Do Until Not (Right(dtgDetail.Columns(4).Value, 1) = "/" Or Right(dtgDetail.Columns(4).Value, 1) = "-")
            dtgDetail.Columns(4).Value = Left(dtgDetail.Columns(4).Value, Len(dtgDetail.Columns(4).Value) - 1)
        Loop
    End If
End Sub

'Set the datagrid as active control
Private Sub dtgDetail_Click()
    If Mode = AddNewEdit Then dtgName = dtgDetail.Name
End Sub

Private Sub dtgDetail_Error(ByVal DataError As Integer, Response As Integer)
    Response = 0
End Sub

Private Sub dtgDetail_KeyDown(KeyCode As Integer, Shift As Integer)
    If Mode <> AddNewEdit Then Exit Sub
    If (Shift = vbCtrlMask And KeyCode = 45) Then
        TBNewLine
    ElseIf (Shift = vbCtrlMask And KeyCode = 46) Then
        TBDeleteLine
    ElseIf (Shift = vbCtrlMask And KeyCode = 83) Then
        TBSave
    End If
End Sub

Private Sub dtgDetail_KeyPress(KeyAscii As Integer)
    
    If Mode <> AddNewEdit Then Exit Sub
    If rsDetail.RecordCount = 0 Then Exit Sub
        
    If KeyAscii = 39 Then KeyAscii = 0 'Apostrophe {'}
    
    If KeyAscii = 13 Then
        Select Case dtgDetail.Col
            Case 0
                If GetValueFrTable("cItemNo", "ITEM", "cItemNo = '" & Trim(dtgDetail.Columns(0).Value) & "'") = "" Then
                    dtgDetail_ButtonClick (0) 'use button click
                Else
                    rsDetail!cItemNo = Trim(dtgDetail.Columns(0).Value) & ""
                    GetInitialItemValues
                End If
            Case 4
                TBNewLine
                dtgDetail.LeftCol = 0
            Case Else
                SendKeys "{Tab}"
        End Select
    Else
        If dtgDetail.Col = 4 Then
            '"-" character
                If (KeyAscii = 45) And lLessAmount Then
                    KeyAscii = 0
                ElseIf KeyAscii = 45 Then
                    lLessAmount = True
                End If

                '"/" character
                If (KeyAscii = 47) And lLessPercent Then
                    KeyAscii = 0
                ElseIf KeyAscii = 47 Then
                    lLessPercent = True
                    lLessAmount = False
                Else
                    lLessPercent = False
                End If
               
                KeyAscii = ValidKeys(KeyAscii, "-/1234567890.", True)
        Else
            KeyAscii = Asc(UCase(Chr(KeyAscii))) 'All Upper Case String
        End If
    End If

End Sub

'Right click menu popup
Private Sub dtgDetail_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Mode <> AddNewEdit Then Exit Sub
    If Button = 2 Then
        dtgName = dtgDetail.Name
        PopupMenu ITGLedgerMain.mnuDetail
    End If
End Sub

Private Sub dtgList_HeadClick(ByVal ColIndex As Integer)
    SortGrid dtgList, ColIndex, rsHeader
End Sub

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
Dim iKey As Integer
    iKey = ToolbarIndex(KeyCode, Shift)
    If iKey <> 0 Then
        If ITGLedgerMain.tbrMain.Buttons(iKey).Enabled = True Then
            ToolbarFunction iKey
        End If
    End If
End Sub

'Set Your Object
Private Sub Form_Load()
        
    Set FrmName = Me
    FormSetup

    AcessBit Me, GetValueFrTable("AccessLevel", "SEC_ACCESSLEVEL", "RoleID = '" & SecUserRole & "' AND [Module] = 'MF05'")
    
    Set rsHeader = New ADODB.Recordset
    Set rsDetail = New ADODB.Recordset
    

    Call LoadComboValues(cboArea, "cParamName", "PARAMETER_USER", "WHERE cType = 'AREA' AND cCompanyID = '" & Trim(COID) & "'", "nOrder")
    Call LoadComboValues(cboTerms, "cParamName", "PARAMETER_USER", "WHERE cType = 'TERMS' AND cCompanyID = '" & Trim(COID) & "'", "nOrder")
    
    FormLocking True
    FormSearch True
    SearchObj True
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, , , , , True, , , , True, , , True
    BitVisible ITGLedgerMain.tbrMain, True, True
    ITGLedgerMain.tbrMain.Buttons("btnFind").ButtonMenus("btnFindP").Enabled = True

    Mode = Find
    txtPMCode.Locked = False
    cboUnit.Visible = False
    
    If GetValueFrTable("lBit", "SYSTEM_OPTION", "cCode = 'ITM_MAN_BARCODE'") = True Then
        If Trim(cboType) = "Customer" Then
            dtgDetail.Columns(4).Visible = False
        End If
        dtgDetail.Columns(5).Visible = True
        dtgDetail.Columns(6).Visible = True
    Else
        dtgDetail.Columns(5).Visible = False
        dtgDetail.Columns(6).Visible = False
    End If
End Sub

'Activate your Toolbar Mode
Private Sub Form_Activate()
    TBBitReload
End Sub

'Release your Object
Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next
    If Mode = AddNewEdit Then
        MsgBox "Unable to close. You are in Add/New/Edit mode." & vbCr & _
            " Must Save or Undo", vbCritical, Me.Caption
        Cancel = True
        Exit Sub
    End If
    
    CloseMenuTab ITGLedgerMain

    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , , , , , , , True
    BitVisible ITGLedgerMain.tbrMain
    ITGLedgerMain.tbrMain.Buttons("btnFind").ButtonMenus("btnFindP").Enabled = False

    
    
    
    
    Set oPrint = Nothing
    Set rsHeader = Nothing
    Set rsDetail = Nothing
    Set connHeader = Nothing
    Set connDetail = Nothing
    
    Set frmMaintPriceMatrix = Nothing

    lCloseWindow = True
    
'    'oForm(Me.Tag).Mode = 1
'    'oForm(Me.Tag).Tag = Me.Tag
End Sub

'Add new record to the recordset
Public Sub TBNew()

    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , True, True, , , True, True, , , , True
    txtPMCode.BackColor = &HE0FFFF
    Mode = AddNewEdit

    If rsHeader.State <> adStateOpen Then
        OpenNewConnection connDetail
        OpenNewConnection connHeader
        OpenRecordsetWithCN rsDetail, "*", "PM_T", connDetail, "WHERE 1 = 0"
        OpenRecordsetWithCN rsHeader, "*", "PM", connHeader, "WHERE 1 = 0"
        SetDataSource
        SetDataField
    Else
        vBM = rsHeader.Bookmark
    End If
    
    rsHeader.AddNew
    rsHeader!cCompanyID = COID
    rsHeader!dDate = Date
    rsHeader!dEffectDate = Date
    rsHeader!cType = "Area"
    rsHeader!cCategory = "Price"
    
    Set FrmName = Me
    FormLocking False
    ClrRequired &HC0&
    SSTab1.ActiveTab = 0
    txtPMCode.SetFocus
    

End Sub

'Undo all changes to the recordset
Public Sub TBUndoAll()
On Error GoTo ErrorHandler

    Mode = Normal
    
    If rsHeader.Status = adRecNew Then TBUndoCurrent
    
    rsHeader.CancelBatch adAffectAll
    rsDetail.CancelBatch adAffectAll
    
    UnbindControls
    
    If rsHeader.RecordCount <> 0 Then rsHeader.Bookmark = vBM
    
    Set FrmName = Me
    FormLocking True
    
    If rsHeader.RecordCount <> 0 Then
        BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, lACDelete, , , True, lACCancel, , , True, True, lACPrint, True
    Else
        RSZero
        Mode = Find
    End If

    sbRS.Panels(2) = ""
    
    SetDataSource
    SetDataField

ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    ElseIf err.Number = -2147217842 Then 'Operation was cancelled. (Error returned by ITGDateBox)
        TBUndoAll
    End If

End Sub

'Undo changes on the current record
Public Sub TBUndoCurrent()
On Error GoTo ErrorHandler

    GetChild
    If rsHeader.Status = adRecNew Then
        rsDetail.CancelBatch adAffectAll
        rsHeader.CancelUpdate
    Else
        rsHeader.CancelBatch adAffectCurrent
        rsDetail.CancelBatch adAffectAll
    End If
   
    If rsHeader.RecordCount = 0 Then RSZero
    
ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    ElseIf err.Number = -2147217842 Then 'Operation was cancelled. (Error returned by ITGDateBox)
        TBUndoCurrent
    End If

End Sub

'Save all changes
Public Sub TBSave()
Dim OKUpdate As Boolean
On Error GoTo ErrHandler

    'Audit Trail
    lBoolean = False



    If Not MandatoryOK Then Exit Sub
    
    OKUpdate = False
    cn.BeginTrans
    connHeader.BeginTrans
    connDetail.BeginTrans
    
    rsHeader.UpdateBatch adAffectAll
    rsDetail.UpdateBatch adAffectAll
        
    cn.CommitTrans
    connHeader.CommitTrans
    connDetail.CommitTrans
    OKUpdate = True
    
    Set FrmName = Me
    FormLocking True
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, lACDelete, , , True, lACCancel, , , True, True, lACPrint, True
    Mode = Normal
    

    
    MsgBox "Record/s successfully saved.", vbInformation, "Communion"
    SetDataSource
    
    sbRS.Panels(2) = ""
    
    'Audit trail
    UpdateLogFile "Price Matrix", Trim(txtPMCode), IIf(lBoolean, "Inserted", "Updated")
        
    
ErrHandler:

    If err.Number = -2147217885 Then
        Resume Next
    ElseIf err.Number = -2147217864 Then
        OKUpdate = True
        cn.RollbackTrans
        connHeader.RollbackTrans
        connDetail.RollbackTrans
        MsgBox "Record cannot be updated. Some values may have been changed by other user/s since last read." & vbCr & _
                "Records will be automatically refreshed. All changes made to the record will be gone upon refresh.", vbInformation, "Communion"
        vBookMark = rsHeader.Bookmark
        UnbindControls
        rsHeader.Requery
        rsDetail.Requery
        BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, lACDelete, , , True, lACCancel, , , True, True, lACPrint, True
        Mode = Normal
        If rsHeader.RecordCount <> 0 Then
            Set FrmName = Me
            FormLocking True
            SetDataField
            SetDataSource
            rsHeader.Bookmark = vBookMark
        Else
            RSZero
        End If
    End If
    If Not OKUpdate Then
        MsgBox "Transaction update failed.", vbInformation, "Communion"
        cn.RollbackTrans
        connHeader.RollbackTrans
        connDetail.RollbackTrans
        ErrorLog err.Number, err.Description, Me.Name 'Error log
    End If

End Sub

'Sets the form & recorset to add/edit mode
Public Sub TBEdit()
    If rsHeader!lCancelled = True Then
        MsgBox "Transaction was already cancelled. Edit is not allowed.", vbExclamation, "Communion"
        Exit Sub
    End If
    If rsHeader!lPosted = True Then
        MsgBox "Transaction was already posted. Edit is not allowed.", vbExclamation, "Communion"
        Exit Sub
    End If
    
    Mode = AddNewEdit
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , True, True, , , True, True, , , , True
    Set FrmName = Me
    
    FormLocking False
    ClrRequired &HC0&
    txtPMCode.Locked = True
    
    SSTab1.ActiveTab = 0
    dtbDate.SetFocus
    vBM = rsHeader.Bookmark
End Sub

'Delete record
Public Sub TBDelete()
On Error GoTo ErrorHandler

    sID = Trim(txtPMCode)
    
    If rsHeader.RecordCount = 0 Then Exit Sub

    If rsHeader!lCancelled = True Then
        MsgBox "Transaction was already cancelled. Deletion is not allowed.", vbExclamation, "Communion"
        Exit Sub
    End If
    If rsHeader!lPosted = True Then
        MsgBox "Transaction was already posted. Delete is not allowed.", vbExclamation, "Communion"
        Exit Sub
    End If
    
    If MsgBox("Are you sure you want to delete this record?", vbQuestion + vbYesNo, "Communion") = vbNo Then Exit Sub
    
    GetChild
    If rsDetail.RecordCount <> 0 Then
        rsDetail.MoveFirst
        Do Until rsDetail.RecordCount = 0
            rsDetail.Delete adAffectCurrent
            If rsDetail.RecordCount <> 0 Then rsDetail.MoveFirst
        Loop
    End If
    
    'Audit trail
    UpdateLogFile "Price Matrix", Trim(txtPMCode), "Deleted"

    rsHeader.Delete adAffectCurrent
    
    rsDetail.UpdateBatch adAffectAll
    rsHeader.UpdateBatch adAffectAll
    

    
    TBPrevRec

    Mode = Normal

    If rsHeader.RecordCount = 0 Then
        RSZero
    End If

ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    ElseIf err.Number = -2147217864 Then
        cn.Execute "DELETE PM_T WHERE cPMID = '" & sID & "' AND cCompanyID = '" & COID & "'"
        cn.Execute "DELETE PM WHERE cPMID = '" & sID & "' AND cCompanyID = '" & COID & "'"
        Resume Next
    End If

End Sub

'Search using the frmITGSearch
Public Sub TBFind()
    Mode = Normal
    txtPMCode.Locked = True
    frmITGSearch.Show vbModal
End Sub

'Search using the recordset primary key
Public Sub TBFindPrimary()
Dim sTemp As String
If Mode = Find Then
    FormWaitShow App.Path & "\Transmit.avi", "Loading data . . ."
        
    OpenNewConnection connHeader
    OpenNewConnection connDetail

    Set rsHeader = Nothing
    Set rsDetail = Nothing
    Set rsHeader = New ADODB.Recordset
    Set rsDetail = New ADODB.Recordset

    sTemp = Trim$(GetSearchString)
    If sTemp = "ERROR" Then
        MsgBox "Only Allows A - Z, 0 - 9, '.', ',' and %(wildcard)", vbExclamation, ""
        BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, , , , , , , , , True, , , True
        txtPMCode.Locked = False
        txtPMCode.SetFocus
        Exit Sub
    End If
          
    OpenRecordsetWithCN rsHeader, "*", "PM", connHeader, IIf(sTemp = "", "", " WHERE " & sTemp)
    'OpenRecordsetWithCN rsDetail, "*", "PM_T", connDetail
                
    OpenRecordsetWithCN rsDetail, "*", "PM_T", connDetail, IIf(sTemp = "", "", " WHERE cPMID IN (SELECT cPMID FROM PM WHERE " & sTemp & ")")
      
    Set FrmName = Me
    FormLocking True

    If rsHeader.RecordCount = 0 Then
        FormWaitHide
        MsgBox "No matching record/s found.", vbInformation, "ComUnion Search"
        RSZero
        FormSearch True
        SearchObj True
        Mode = Find
        

        
        Exit Sub
    End If
    SetDataSource
    SetDataField
    txtPMCode.BackColor = &HE0FFFF
    Mode = Normal
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, lACDelete, , , True, lACCancel, , , True, True, lACPrint, True

    FormWaitHide
Else
    RSZero
    FormSearch True
    SearchObj True
    Mode = Find
End If

End Sub

'Reload menu buttons (do not delete this sub)
Public Sub TBBitReload()
    BitVisible ITGLedgerMain.tbrMain, True, True
    ITGLedgerMain.tbrMain.Buttons("btnFind").ButtonMenus("btnFindP").Enabled = True
    BitReload ITGLedgerMain, Me, ITGLedgerMain.tbrMain, sBit
    Set FrmName = Me
    dtgName = dtgDetail.Name
End Sub

'Close active window
Public Sub TBCloseWindow()
    Unload Me
End Sub

'Move first
Public Sub TBFirstRec()
    If rsHeader.State <> adStateOpen Then Exit Sub
    MoveFirst rsHeader

End Sub

'Move previuos
Public Sub TBPrevRec()
    If rsHeader.State <> adStateOpen Then Exit Sub
    MovePrevious rsHeader
    

End Sub

'Move next
Public Sub TBNextRec()
    If rsHeader.State <> adStateOpen Then Exit Sub
    MoveNext rsHeader


End Sub

'Move last
Public Sub TBLastRec()
    If rsHeader.State <> adStateOpen Then Exit Sub
    MoveLast rsHeader

End Sub

'Add new line to the detail recordset
Public Sub TBNewLine()
On Error GoTo err
    If dtgName = "dtgDetail" Then
        rsDetail.AddNew
        rsDetail!cCompanyID = COID
        rsDetail!cPMID = Trim(rsHeader!cPMID)
        dtgDetail.Col = 0
        GetChild
        If rsDetail.RecordCount <> 0 Then rsDetail.MoveLast
        dtgDetail.SetFocus
'    End If
    RepName = "PriceMatrix"
'    frmITGPickList.mType = ProductPM
'    frmITGPickList.Show vbModal
    frmITGPicker.zType = QProduct
    frmITGPicker.Show vbModal
    rsDetail!cItemNo = frmITGPicker.zCode & ""
    rsDetail!cPartNo = frmITGPicker.zPart & ""
    rsDetail!cDesc = frmITGPicker.zName & ""
    rsDetail!cUnit = GetValueFrTable("cUnit", "ITEM", "cItemNo = '" & frmITGPicker.zCode & "" & "'")
    End If
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , True, True, , , True, True, , , , True
    txtPMCode.Locked = True
err:
If err.Number = -2147217887 Then Resume Next

End Sub

'Delete line in the detail recordset
Public Sub TBDeleteLine()
On Error GoTo ErrorHandler
    
    If rsDetail.RecordCount > 0 Then
    If MsgBox("This action will clear all item details on the grid. " & vbCr & _
            "Do you want to proceed?", vbYesNo, "Communion") = vbNo Then Exit Sub
    End If

    GetChild

    If rsDetail.RecordCount <> 0 Then rsDetail.MoveFirst
    Do Until rsDetail.EOF
        rsDetail.Delete
        rsDetail.MoveNext
    Loop
    
    GetChild
    If dtgName = dtgDetail.Name Then
        If rsDetail.RecordCount = 0 Then Exit Sub
        vBookMark = dtgDetail.Bookmark
        GetChild
        dtgDetail.Bookmark = vBookMark
        rsDetail.Delete adAffectCurrent
    End If
    GetChild
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , True, True, , , True, True, , , , True
ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    End If
End Sub

'Undo All
Public Sub TBUndoLineAll()
On Error GoTo ErrorHandler

    MsgBox "Unavailable on " & Me.Name

ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    End If

End Sub

'Undo current line
Public Sub TBUndoLineCurrent()
    MsgBox "Unavailable on " & Me.Name
End Sub

'Post current record
Public Sub TBPostRecord()
On Error GoTo TheSource
    
    If rsHeader.RecordCount = 0 Then Exit Sub

    If rsHeader!lCancelled = True Then
        MsgBox "Transaction was already cancelled. Approval is not allowed", vbExclamation, "Comunion"
        Exit Sub
    End If
    
    If rsHeader!lPosted = True Then
        MsgBox "Transaction was already posted.", vbExclamation, "Comunion"
        Exit Sub
    End If
    
'    If rsHeader!lApproved = True Then
'        MsgBox "Transaction was already approved.", vbExclamation, "Comunion"
'        Exit Sub
'    End If
    
    If MsgBox("Are you sure you want to approve this record?", vbQuestion + vbYesNo, "Comunion") = vbNo Then Exit Sub

    'Audit trail
    UpdateLogFile "Price List", Trim(txtPMCode), "Approved"

    cn.Execute ("UPDATE PM SET lApproved = 1,lPosted = 1 WHERE cPMID = '" & Trim(txtPMCode) & "' AND cCompanyID = '" & COID & "'")
        
    sbRS.Panels(4) = "APPROVED"
    Mode = Normal
    
    rsHeader!lApproved = True
'    rsHeader!cApprovedBy = SecUserID
    rsHeader.UpdateBatch adAffectAll
    
TheSource:
    If err.Number = -2147217885 Then
        Resume Next
    End If
End Sub

'Cancel current record
Public Sub TBCancelRecord()
On Error GoTo ErrorHandler
    
    If rsHeader.RecordCount = 0 Then Exit Sub

    If rsHeader!lCancelled = True Then
        MsgBox "Transaction was already cancelled.", vbExclamation, "Communion"
        Exit Sub
    End If
    If rsHeader!lPosted = True Then
        MsgBox "Transaction was already posted. Cancel is not allowed.", vbExclamation, "Communion"
        Exit Sub
    End If
    
    If MsgBox("Are you sure you want to cancel this record?", vbQuestion + vbYesNo, "Communion") = vbNo Then Exit Sub
    
    'Audit trail
    UpdateLogFile "Price Matrix", Trim(txtPMCode), "Cancelled"

    cn.Execute ("UPDATE PM SET lCancelled = 1 WHERE cPMID = '" & Trim(txtPMCode) & "' AND cCompanyID = '" & COID & "'")
    sbRS.Panels(5) = "CANCELLED"
    Mode = Normal
    
    rsHeader!lCancelled = True
    rsHeader.UpdateBatch adAffectAll

ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    End If

End Sub

'Print
Public Sub TBPrintRecord()
    'If Trim(txtPMCode) = "" Then Exit Sub
    'cModule = "PM_Invoice"
    'oPrint.PrintReceipt Trim(txtPMCode)
End Sub

'Sets the data source of the controls
Sub SetDataSource()
    Set FrmName = Me
    BindControls rsHeader
    Set dtgList.DataSource = rsHeader
    Set dtgDetail.DataSource = rsDetail
    
    
End Sub

'Sets the data field for every bounded controls
Sub SetDataField()
    With rsHeader
        txtPMCode.DataField = !cPMID
        txtPMDesc.DataField = !cDesc
        dtbDate.DataField = !dDate
        dtbEffecDate.DataField = !dEffectDate
        txtType.DataField = !cType
        txtCategory.DataField = !cCategory
        txtCode.DataField = !cReference
    End With
End Sub

Private Sub optCategory_Click(Index As Integer)
    If Mode <> AddNewEdit Then Exit Sub
    txtCategory = optCategory(Index).Caption
End Sub

Private Sub optCategory_KeyPress(Index As Integer, KeyAscii As Integer)
    SendKeysTab KeyAscii
End Sub

Private Sub rsHeader_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
On Error GoTo ErrorHandler

    If Not (rsHeader.EOF) Or Not (rsHeader.BOF) Then
        'Status bar setup
        sbRS.Panels(1) = "Record: " & IIf((rsHeader.AbsolutePosition = -2), "0", rsHeader.AbsolutePosition) & "/" & rsHeader.RecordCount

        If rsHeader.Status <> adRecNew Then
            txtPMCode.Locked = True
        Else
            txtPMCode.Locked = False
        End If

        If Mode = AddNewEdit Then
            Select Case rsHeader.Status
                Case adRecNew
                    sbRS.Panels(2) = "New"
                Case adRecModified
                    sbRS.Panels(2) = "Modified"
                Case Else
                    sbRS.Panels(2) = ""
            End Select
        Else
            sbRS.Panels(2) = ""
        End If
        
        GetChild
        
        If rsHeader!lCancelled = True Then
            sbRS.Panels(5) = "CANCELLED"
        Else
            sbRS.Panels(5) = ""
        End If
        If rsHeader!lPosted = True Then
            sbRS.Panels(4) = "POSTED"
        Else
            sbRS.Panels(4) = ""
        End If
    Else
        sbRS.Panels(1) = "Record: 0/0"
        sbRS.Panels(2) = ""
        txtPMCode.Locked = False
    End If

    If Mode = AddNewEdit Then
        dtgDetail.Refresh
    End If

ErrorHandler:
    'Err.Number -2147217885
    'Description - Row handle referred to a deleted row or a row marked for deletion.
    If err.Number = -2147217885 Then
        Resume Next
    End If

End Sub

Private Sub Timer1_Timer()
    If Mode = AddNewEdit Then
        SSTab1.TabEnabled(1) = False
    Else
        SSTab1.TabEnabled(1) = True
    End If
End Sub

Private Sub txtCategory_Change()
    Select Case txtCategory
        Case "Price"
            optCategory(0).Value = True
        Case "Discount"
            optCategory(1).Value = True
    End Select
End Sub

Private Sub txtCode_Change()
    txtName = ""
    Select Case Trim(cboType)
        Case "Area"
            If Trim(txtCode) <> "" Or txtCode <> vbNullString Then
                cboArea = Trim(txtCode)
            Else
                cboArea.ListIndex = -1
            End If
        Case "Terms"
            If Trim(txtCode) <> "" Or txtCode <> vbNullString Then
                cboTerms = Trim(txtCode)
            Else
                cboTerms.ListIndex = -1
            End If
        Case "Customer Type"
            If Trim(txtCode) <> "" Or txtCode <> vbNullString Then
                cboCType = Trim(txtCode)
            Else
                cboCType.ListIndex = -1
            End If
        Case "Customer"
            txtName = GetValueFrTable("cName", "CLIENT_CUSTOMER", "cCode = '" & Trim(txtCode) & "'")
        Case "Market Segment"
            txtName = GetValueFrTable("cDescription", "CLASSIFICATION", "cClassCode = '" & Trim(txtCode) & "' AND cType = 'MS'")
    End Select
    
End Sub

Private Sub txtCode_LostFocus()
    If Mode <> AddNewEdit Then Exit Sub
    'If Trim(txtName) = "" And Trim(txtCode) <> "" Then cmdPickCode_Click
End Sub

Private Sub txtPMCode_LostFocus()
    'Does Code Already Exist
    If Mode = AddNewEdit Then
        If Trim(txtPMCode) = "" Then
            MsgBox "Empty primary input.", vbInformation, "Communion"
            If FrmName.Name <> Me.Name Then PreviousTab frmComUnionMenuTab
            txtPMCode.SetFocus
        Else
            If rsHeader.Status <> adRecNew Then Exit Sub
            txtPMCode = Trim(txtPMCode)
            If IDExisting(rsHeader, "cPMID", "PM", Trim(rsHeader!cPMID)) Then
                MsgBox "Price Matrix No. already exist.", vbInformation, "ITGLedger"
                If FrmName.Name <> Me.Name Then PreviousTab frmComUnionMenuTab
                txtPMCode.SetFocus
            End If
        End If
    End If
End Sub

Private Sub txtType_Change()
    If Trim(txtType) <> "" Or txtType <> vbNullString Then
        cboType = Trim(txtType)
    Else
        cboType.ListIndex = -1
    End If
    Select Case Trim(cboType)
        Case "Customer", "Market Segment"
'            txtCode.Text = rsHeader!cReference
            txtCode.Visible = True
            cmdPickCode.Visible = True
            txtName.Visible = True
            cboArea.Visible = False
            cboTerms.Visible = False
            cboCType.Visible = False
        Case "Area"
            cboArea.Visible = True
            cboTerms.Visible = False
            cboCType.Visible = False
            txtCode.Visible = False
            cmdPickCode.Visible = False
            txtName.Visible = False
        Case "Terms"
            cboArea.Visible = False
            cboTerms.Visible = True
            cboCType.Visible = False
            txtCode.Visible = False
            cmdPickCode.Visible = False
            txtName.Visible = False
        Case "Customer Type"
            cboArea.Visible = False
            cboTerms.Visible = False
            cboCType.Visible = True
            txtCode.Visible = False
            cmdPickCode.Visible = False
            txtName.Visible = False
    End Select
End Sub

'Check if all mandatory fields are complete
Function MandatoryOK() As Boolean

    MandatoryOK = True

    If Trim(txtPMCode) = "" Then
        MandatoryOK = False
        MsgBox "Field 'Invoice Number' is mandatory. Null value is not allowed.", vbInformation, "Communion"
        txtPMCode.SetFocus
        Exit Function
    End If
    
    If rsHeader.Status = adRecNew Then
        If IDExisting(rsHeader, "cPMID", "PM", Trim(rsHeader!cPMID)) Then
            MandatoryOK = False
            MsgBox "Price Matrix No. already exist.", vbInformation, "Communion"
            txtPMCode.SetFocus
            Exit Function
        End If
    End If

    'Required fields
    If Trim(txtPMDesc) = "" Then
        MandatoryOK = False
        MsgBox "Field 'Description' is mandatory. Null value is not allowed.", vbInformation, "Communion"
        txtPMDesc.SetFocus
        Exit Function
    ElseIf Trim(dtbDate.Text) = "__/__/____" Then
        MandatoryOK = False
        MsgBox "Field 'Transaction Date' is mandatory. Null value is not allowed.", vbInformation, "Communion"
        dtbDate.SetFocus
        Exit Function
    ElseIf Trim(dtbEffecDate.Text) = "__/__/____" Then
        MandatoryOK = False
        MsgBox "Field 'Transaction Date' is mandatory. Null value is not allowed.", vbInformation, "Communion"
        dtbDate.SetFocus
        Exit Function
    ElseIf Trim(txtType) = "" Then
        MandatoryOK = False
        MsgBox "Field 'Type' is mandatory. Null value is not allowed.", vbInformation, "Communion"
        cboType.SetFocus
        Exit Function
    ElseIf Trim(txtCode) = "" Then
        MandatoryOK = False
        MsgBox "Field 'Reference' is mandatory. Null value is not allowed.", vbInformation, "Communion"
        txtCode.SetFocus
        Exit Function
    End If
    
    GetChild
    
    'Transaction without details
    If rsDetail.RecordCount = 0 Then
        MandatoryOK = False
        MsgBox "Cannot save transaction without details.", vbInformation, "Communion"
        dtgDetail.SetFocus
        Exit Function
    End If
    
    If rsDetail.RecordCount <> 0 Then rsDetail.MoveFirst
    Do Until rsDetail.EOF
        If rsDetail.Status = (adRecNew) Or rsDetail.Status = (adRecModified) Then
            If IsNull(rsDetail!cItemNo) Then
                rsDetail.Delete
            ElseIf Trim(rsDetail!cItemNo) = "" Then
                rsDetail.Delete
            Else
                rsDetail.MoveNext
            End If
        Else
            rsDetail.MoveNext
        End If
    Loop

    GetChild

    If rsDetail.RecordCount < 1 Then
        MsgBox "Cannot save transaction without details.", vbExclamation, "Communion"
        MandatoryOK = False
        Exit Function
    End If

End Function

'Filter detail recordset to header's primary
Private Sub GetChild()
    rsDetail.Filter = "cPMID = '" & Trim(rsHeader!cPMID) & "'"
End Sub

'Sets the form if record number is zero
Private Sub RSZero()
    sbRS.Panels(1) = "Record: 0/0"
    sbRS.Panels(2) = ""
    sbRS.Panels(4) = ""
    sbRS.Panels(5) = ""
    
    Set dtgDetail.DataSource = Nothing
    dtgDetail.Refresh
    
    Set FrmName = Me
    UnbindControls
    TextClearing
    FormLocking True
    
    If rsHeader.State = adStateOpen Then rsHeader.Close
    If rsDetail.State = adStateOpen Then rsDetail.Close
    
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, , , , , , , , , True, , , True
    
    txtPMCode.Locked = False
    txtPMCode.SetFocus
    
    Mode = Find
    
End Sub

Sub SearchObj(lEnable As Boolean)
    dtbDate.Enabled = lEnable
    cboType.Enabled = lEnable
End Sub

'Add DR Detals from picklist to details recordset
Public Sub AddDetailsFromList()
'On Error Resume Next
    GetChild
    With frmITGPickList.lvwList
        For i = 1 To .ListItems.Count
            If .ListItems(i).Checked = True Then
                rsDetail.AddNew
                rsDetail!cCompanyID = COID
                rsDetail!cPMID = rsHeader!cPMID
                If GetValueFrTable("lBit", "SYSTEM_OPTION", "cCode = 'ITM_MAN_BARCODE'") = True Then
                    rsDetail!cPartNo = Trim(.ListItems(i).SubItems(2))
                    rsDetail!cItemNo = Trim(.ListItems(i).Text) 'GetValueFrTable("cItemNo", "ITEM", "cPartNo = '" & Trim(.ListItems(i).Text) & "'")
                Else
                    rsDetail!cItemNo = Trim(.ListItems(i).Text)
                End If
                rsDetail!cDesc = Trim(.ListItems(i).SubItems(1))
                GetInitialItemValues
            End If
        Next i
    End With
    GetChild
End Sub


'Gets initital item values
Private Sub GetInitialItemValues()
    With rsDetail
        If GetValueFrTable("lBit", "SYSTEM_OPTION", "cCode = 'ITM_MAN_BARCODE'") = False Then
            !cDesc = Trim(GetValueFrTable("cDesc", "ITEM", "cItemNo = '" & Trim(!cItemNo) & "'")) & ""
            !cUnit = Trim(GetValueFrTable("cUnit", "ITEM", "cItemNo = '" & Trim(!cItemNo) & "'")) & ""
            dtgDetail.Col = 3
            !nPrice = Trim(GetValueFrTable("nSRPrice", "ITEM", "cItemNo = '" & Trim(!cItemNo) & "'")) & ""
        Else
            !cDesc = Trim(GetValueFrTable("cDesc", "ITEM", "cPartNo = '" & Trim(!cPartNo) & "' and cItemNo = '" & Trim(!cItemNo) & "'")) & ""
            !cUnit = Trim(GetValueFrTable("cUnit", "ITEM", "cPartNo = '" & Trim(!cPartNo) & "' and cItemNo = '" & Trim(!cItemNo) & "'")) & ""
            dtgDetail.Col = 3
            !nPrice = Trim(GetValueFrTable("nSRPrice", "ITEM", "cPartNo = '" & Trim(!cPartNo) & "' and cItemNo = '" & Trim(!cItemNo) & "'")) & ""
        End If
    End With
End Sub

Private Function GetSearchString() As String
On Error GoTo ErrorHandler
Dim sWhere As String

    GetSearchString = True

    If Trim$(txtPMCode.Text) <> "" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " cPMID LIKE '" & Trim$(txtPMCode.Text) & "%'"
    End If

    If Trim$(dtbDate.Text) <> "__/__/____" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " dDate = '" & Trim$(dtbDate.Text) & "'"
    End If
    
    If Trim$(txtType.Text) <> "" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " cType LIKE '" & Trim$(txtType.Text) & "%'"
    End If

    GetSearchString = Trim$(sWhere)

    Exit Function
ErrorHandler:
    GetSearchString = "ERROR"
End Function




